package com.siun.dk.module;

import com.aw.baselib.util.AwDataUtil;
import com.aw.baselib.util.AwDateUtil;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.siun.chery.R;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class HintAdapter extends BaseQuickAdapter<String, BaseViewHolder> {

    private List<String> mList = new ArrayList<>();

    public HintAdapter() {
        super(R.layout.adapter_hint);
        if(mList == null) {
            mList = new ArrayList<>();
        }
    }

    @Override
    protected void convert(BaseViewHolder helper, final String bean) {
        helper.setText(R.id.tv_content, "【" + AwDateUtil.formatDate(new Date(), "HH:mm:ss")+ "】 " + bean);

    }

    public void addAllData(List<String> dataList) {
        this.mList = dataList;
        this.setNewData(mList);
        notifyDataSetChanged();
    }

    public void clearData() {
        if(mList != null) {
            int startPosition = 0;//hasHeader is 1
            int preSize = this.mList.size();
            if(preSize > 0) {
                this.mList.clear();
                notifyItemRangeRemoved(startPosition, preSize);
            }
        }
    }
}
